package String_process;

import java.util.Scanner;

import static com.sun.org.apache.xalan.internal.lib.ExsltStrings.split;

/**
 * @author dx
 * @version 1.0
 * @date 2022/5/11 14:50
 * @description: 输入一个英文句子，翻转句中的单词顺序，但单词内字符的顺序不变，为简单起见，标点符号和普通字母的一样处理
 * 例如输入字符串"I am a student." 则输出"student. a am I"
 */
public class ReverseSentense {
    public static void main(String[] args) {
        Scanner sr = new Scanner(System.in);
        String s = sr.nextLine();
        String ans = new solution_ReverseSentense().reverseLeftWords(s);
//        String ans = new solution_ReverseSentense().Reverse(s);
        System.out.println(ans);
    }
}
 class solution_ReverseSentense {
    public String reverseLeftWords(String s) {
        String res =Reverse(s.trim());
        StringBuffer sb = new StringBuffer();
        int size = res.split(" ").length;
        for(String x: res.split("\\s+")){
           sb.append(Reverse(x));
               sb.append(" ");
        }
        return sb.toString().trim();
    }
    public String Reverse(String s){
        int len = s.length();
        char [] ans = new char[len];
        int i = len-1;
        int j = 0;
        while(i>=0){
            ans[j++] = s.charAt(i--);
        }
        String res = new String(ans,0,len);
        return res;
    }
}
